import Vue from 'vue'
import Vuex from 'vuex'
import { getToken, setToken, removeToken } from '@/utils/auth'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: getToken(),
    userId: '',
    userName:""
  },
  getters: {},
  mutations: {
    storeToken (state, payload) {
      state.token = payload.token
      state.userId = payload.userId
      state.userName = payload.userName

      setToken(payload.token)
    },
    delToken () {
      removeToken()
    }
  },
  actions: {},
  modules: {}
})
